/*******************************************************************\
| Scene.h
|
| CREATED:		30.3.2009
| DESCRIPTION:
| 
| Class containing the scene definition with all objects in the scene
\********************************************************************/
#ifndef SCENE_H
#define SCENE_H

#include "Object.h"
#include "Light.h"
#include "Camera.h"

namespace PhotonMapping
{

//*****************************************************************************
// class overview:
//   
//-----------------------------------------------------------------------------
class Scene
{
	private:
		// scenes can only be created using Load
		Scene();

	public:
		static ScenePtr Load(const tchar* p_Filename);

		// returns the objects in the scene
		const std::vector<ObjectPtr>& GetObjects() const;

		// returns the lights in the scene
		const std::vector<LightPtr>& GetLights() const;

		// returns the materials in the scene
		const std::vector<MaterialPtr>& GetMaterials() const;

		// return the camera
		const Camera& GetCamera() const;

	private:

		// -------------------------------------------------------------
		// Parsing helpers:
		// parses material parameters
		bool ParseMaterialParams(tifstream& p_FileStream);

		// parses sphere parameters
		bool ParseSphereParams(tifstream& p_FileStream);

		// parses plane parameters
		bool ParsePlaneParams(tifstream& p_FileStream);

		// parses point light parameters
		bool ParsePointLightParams(tifstream& p_FileStream);

		// parses area light parameters
		bool ParseAreaLightParams(tifstream& p_FileStream);

		// parses camera parameters
		bool ParseCameraParams(tifstream& p_FileStream);

		// parses triangle list parameters
		bool ParseTriangleListParams(tifstream& p_FileStream);

		// helper functions to parse parameter values
		bool ParseParamInt(tifstream& p_FileStream, intx& p_Value, const tchar* p_ParamName);
		bool ParseParamFloat(tifstream& p_FileStream, float& p_Value, const tchar* p_ParamName);
		bool ParseParamVec3(tifstream& p_FileStream, Math::Vector3& p_Value, const tchar* p_ParamName);
		bool ParseParamColor(tifstream& p_FileStream, Color& p_Value, const tchar* p_ParamName);
		bool ParseCoordinates(tifstream& p_FileStream, Math::Vector3& p_Value, const tchar* p_ParamName);

	private:

		// maximum material number
		static const uintx MaxNumMaterials = 100;

		// objects in scene
		std::vector<ObjectPtr> m_Objects;

		// lights in the scene
		std::vector<LightPtr> m_Lights;

		// materials used by the scene objects
		std::vector<MaterialPtr> m_Materials;

		// camera
		Camera m_Camera;
};


} // PhotonMapping

#endif // SCENE_H